package com.tyd.cams.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.tyd.cams.R;
import com.tyd.cams.entity.ClassInfobean;
import com.tyd.cams.entity.FanKabean;

import java.util.List;

/**
 * @author: TYD
 * @作者: 唐YaDong
 * @date: 2021/3/15 2:27
 * @description：ClassRecyclerAdapter
 * @描述：ClassRecyclerAdapter
 * @版本：1.0
 */
public class ClassRecyclerAdapter extends RecyclerView.Adapter<ClassRecyclerAdapter.ViewHplder> {
    Context context;
    List<ClassInfobean> classInfobeans;

    public ClassRecyclerAdapter(Context context, List<ClassInfobean> classInfobeans) {
        this.context = context;
        this.classInfobeans = classInfobeans;
    }

    LayoutInflater layoutInflater;

    @NonNull
    @Override
    public ViewHplder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = layoutInflater.from(parent.getContext()).inflate(R.layout.class_item_meun, parent
                , false);
        return new ViewHplder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHplder holder, int position) {
        ClassInfobean classInfobean = classInfobeans.get(position);
        holder.class_name.setText("班级名称:"+classInfobean.getClassName());
        holder.class_master.setText("导员:"+classInfobean.getMasterName());
        holder.class_leave.setText("届名:"+classInfobean.getGradeName());
        holder.class_num.setText("学生"+classInfobean.getClassStuNum()+"名");
//        holder.class_num.setText(classInfobean.getCid());
    }

    @Override
    public int getItemCount() {
        return classInfobeans == null ? 0 : classInfobeans.size();
    }

    public class ViewHplder extends RecyclerView.ViewHolder {
        private TextView class_name;
        private TextView class_master;
        private TextView class_leave;
        private TextView class_num;

        public ViewHplder(@NonNull View itemView) {
            super(itemView);
            class_name = itemView.findViewById(R.id.class_name);
            class_master = itemView.findViewById(R.id.class_master);
            class_leave = itemView.findViewById(R.id.class_leave);
            class_num = itemView.findViewById(R.id.class_num);
        }
    }
}
